<!DOCTYPE html>
<html>
  <head>
    <title>SRPC Simple Plug-in</title>
  </head>
  <body onload="nacllib.waitForModulesAndRunTests();"
        onunload="nacllib.cleanUp();" >
<script type="text/javascript">
//<![CDATA[
function fortytwo() {
  try {
    alert(document.getElementById('pluginobj').fortytwo());
  } catch(e) {
    alert(e);
  }
}

function helloworld() {
  try {
    alert(document.getElementById('pluginobj').helloworld());
  } catch(e) {
    alert(e);
  }
}
//]]>
</script>

<h1>Native Client SRPC Simple Plug-in</h1>
<p>
  <button onclick='fortytwo()'>Call fortytwo()</button>
  <button onclick='helloworld()'>Call helloworld()</button>
  <embed name="nacl_module"
         id="pluginobj"
	 width=0 height=0
         type="application/x-nacl-srpc" />
  <embed name="nacl_module"
         id="pluginobj2"
	 width=0 height=0
	 src="nacl/client.nexe"
         type="application/x-nacl-srpc" />
	 </p>
<script type="text/javascript">
	var nexes = 'x86-32: nacl/client.nexe\n'
			+ 'x86-64: nacl/client.nexe\n'
			+ 'ARM: nacl/client.nexe ';
	pluginobj.nexes=nexes;								
</script>

<p>If the plug-in is working correctly, a click on the "Call fortytwo" button
  should open a popup dialog containing <b>42</b> as value.</p>

<p> Clicking on the "Call helloworld" button
  should open a popup dialog containing <b>hello, world</b> as value.</p>

<h2>Status</h2>
<div id=status>NO-STATUS</div>

<script type="text/javascript" src="nacl_js_lib.js"></script>
<script type="text/javascript">
//<![CDATA[
var nacllib = new NaclLib(document.getElementsByName("nacl_module"),
                          document.getElementById("status"),
                          50);

nacllib.test = function() {
  var plugin = document.getElementById("pluginobj");
  if ('42' != plugin.fortytwo()) {
    return "expected 42";
  }

  if ('hello, world.' != plugin.helloworld()) {
    return "expected 'hello, world.'";
  }

  return "";
};
//]]>
</script>

  </body>
</html>
